package jgl.vajra.operator.part.mine.viewModel;

import java.util.List;
import java.util.Map;

import jgl.vajra.operator.bean.LieEarnAmountBean;
import jgl.vajra.operator.bean.LieEarnCommissionBean;
import jgl.vajra.operator.part.mine.contract.LieEarnContract;
import jgl.vajra.operator.part.mine.model.LieEarnModel;
import jgl.vajra.operator.widget.mvvm.factory.CreateModel;
import jgl.vajra.operator.widget.retrofithelper.rxsubscriber.ProgressObserver;
import jgl.vajra.operator.widget.utils.ToastUtils;

@CreateModel(LieEarnModel.class)
public class LieEarnViewModel extends LieEarnContract.ViewModel{
    @Override
    public void getLieEarnData(Map<String, Object> map) {
        mModel.getLieEarnData(map).subscribe(new ProgressObserver<LieEarnAmountBean>(false,this) {
            @Override
            public void _onNext(LieEarnAmountBean data) {
                mView.returnLieEarnAmountData(data);
            }
        });
    }

    @Override
    public void getLieEarnCommissionData(Map<String, Object> map) {
        mModel.getLieEarnCommissionData(map).subscribe(new ProgressObserver<List<LieEarnCommissionBean>>(false,this) {
            @Override
            public void _onNext(List<LieEarnCommissionBean> data) {
                mView.returnLieEarnCommissionBean(data);
            }
        });
    }

    @Override
    public void getSpreadLevelData(Map<String, Object> map) {
        mModel.getSpreadLevelData(map).subscribe(new ProgressObserver<String>(false,this) {
            @Override
            public void _onNext(String data) {
                mView.returnSpreadLevelData(data);
            }
        });
    }

    @Override
    public void getLieEarnBalanceData(Map<String, Object> map) {
        mModel.getLieEarnBalanceData(map).subscribe(new ProgressObserver<String>(true,this) {
            @Override
            public void _onNext(String data) {
                mView.returnLieEarnBalanceData(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }

    @Override
    public void getWithdrawalBalanceData(Map<String, Object> map) {
        mModel.getWithdrawalBalanceData(map).subscribe(new ProgressObserver<String>(false,null) {
            @Override
            public void _onNext(String data) {
                ToastUtils.showShort(data);
            }

            @Override
            public void _onError(String errorMessage, int errorCode) {
                super._onError(errorMessage, errorCode);
            }
        });
    }
}
